// Agent vegetable in project skygarden

/* Initial beliefs and rules */
last_status(green).

+finished_planting[source(r1)] : last_status(green)
	<-	//.abolish(finished_planting);
		!planting(veg).
		
+finished_planting[source(r1)].
/* Initial goals */

/* Plans */
+!wait_for_send : true
		<-	.my_name(Name);
			pos(X,Y);
			.send(r2,tell,my_info(Name,X,Y)).
		
+!planting(veg) : true
	<-	.random(R);
		.wait(R * 15000);
		?pos(X,Y);
		changecolor(red,X,Y);
		-+last_status(red);
		.send(r2,tell,come_with_me);
		!prepareWilt(veg).

+!prepareWilt(veg) : true
	<- 	.wait(10000);
		?pos(X,Y);
		changecolor(gray,X,Y);
		-+last_status(gray);
		.send(r2,tell,im_died).
		
+!who_die(X,Y) : pos(VX,VY) & VX==X & VY==Y
	<-	-+last_status(green);
		.abolish(finished_planting);
		.drop_all_desires.
	
+!who_die(_,_).